<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Custom Visual Line graph in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Custom-Visual-Line-graph/m-p/362313#M10807</link>
    <description>&lt;P&gt;I'm trying to create a custom visual which has a line graph. I'm trying to create the below D3 line graph but getting type errors.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://bl.ocks.org/emmasaunders/f55caf3a742aac10a5d44f58374bf343" target="_blank"&gt;https://bl.ocks.org/emmasaunders/f55caf3a742aac10a5d44f58374bf343&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;var data: LineData[] = this.dataForLineGraph(options); //A function which gets data for line chart
            var max = 0;
            var minDate = new Date();
            var maxDate = new Date();
            max = d3.max(data, function(d) { return d.m1; });
	        minDate = d3.min(data, function(d) {return d.date; });
		    maxDate = d3.max(data, function(d) { return d.date; });	

 
            var margin = {top: 20, right: 40, bottom: 30, left: 30},
                width = options.viewport.width - margin.left - margin.right,
                height = options.viewport.height - margin.top - margin.bottom - 50;

            d3.selectAll('svg').remove();

            var svg = d3.select('.linediv').append("svg")
                .attr("width", width + margin.left + margin.right)
                .attr("height", height + margin.top + margin.bottom)
                .append("g")
                .attr("transform", "translate(" + (margin.left) + "," + margin.top + ")");

            var y = d3.scale.linear()
                .domain([0,max])
                .range([height,0]);
    
            var x = d3.time.scale()
                .domain([minDate,maxDate])
                .range([0,width]);
    
            var yAxis = d3.svg.axis()
                .orient("left")
                .scale(y);
                    
            var xAxis = d3.svg.axis()
                .orient("bottom")
                .scale(x);
    
            svg.append("g")
			    .attr("class","axis x")
			    .attr("transform","translate(0,"+height+")")
			    .call(xAxis);
			
		    svg.append("g")
			    .attr("class","axis y")
                .call(yAxis);
                
            var line = d3.svg.line()
                .x(function(d){ return x(d.date); })//error
                .y(function(d){ return y(d.m1); })//error
                .interpolate("cardinal"); 

            svg.append("path")
                .attr("class","line")
                .attr("d",function(d){ return line(data); }) //error&lt;/PRE&gt;&lt;P&gt;The error says:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Type LineData[] is not assignable to type [number.number].&lt;/P&gt;&lt;P&gt;Property 0 is missing in the type LineData[]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;LineData is an interface and it looks like below.&lt;/P&gt;&lt;PRE&gt;export interface LineData{
        item: string;
        date: Date;
        m1: number;
        m2: number;
        m3: number;
        m4: number;
        m5: number;
        m6: number;
      }&lt;/PRE&gt;</description>
    <pubDate>Wed, 21 Feb 2018 13:43:28 GMT</pubDate>
    <dc:creator>satishr</dc:creator>
    <dc:date>2018-02-21T13:43:28Z</dc:date>
    <item>
      <title>Custom Visual Line graph</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Custom-Visual-Line-graph/m-p/362313#M10807</link>
      <description>&lt;P&gt;I'm trying to create a custom visual which has a line graph. I'm trying to create the below D3 line graph but getting type errors.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://bl.ocks.org/emmasaunders/f55caf3a742aac10a5d44f58374bf343" target="_blank"&gt;https://bl.ocks.org/emmasaunders/f55caf3a742aac10a5d44f58374bf343&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;var data: LineData[] = this.dataForLineGraph(options); //A function which gets data for line chart
            var max = 0;
            var minDate = new Date();
            var maxDate = new Date();
            max = d3.max(data, function(d) { return d.m1; });
	        minDate = d3.min(data, function(d) {return d.date; });
		    maxDate = d3.max(data, function(d) { return d.date; });	

 
            var margin = {top: 20, right: 40, bottom: 30, left: 30},
                width = options.viewport.width - margin.left - margin.right,
                height = options.viewport.height - margin.top - margin.bottom - 50;

            d3.selectAll('svg').remove();

            var svg = d3.select('.linediv').append("svg")
                .attr("width", width + margin.left + margin.right)
                .attr("height", height + margin.top + margin.bottom)
                .append("g")
                .attr("transform", "translate(" + (margin.left) + "," + margin.top + ")");

            var y = d3.scale.linear()
                .domain([0,max])
                .range([height,0]);
    
            var x = d3.time.scale()
                .domain([minDate,maxDate])
                .range([0,width]);
    
            var yAxis = d3.svg.axis()
                .orient("left")
                .scale(y);
                    
            var xAxis = d3.svg.axis()
                .orient("bottom")
                .scale(x);
    
            svg.append("g")
			    .attr("class","axis x")
			    .attr("transform","translate(0,"+height+")")
			    .call(xAxis);
			
		    svg.append("g")
			    .attr("class","axis y")
                .call(yAxis);
                
            var line = d3.svg.line()
                .x(function(d){ return x(d.date); })//error
                .y(function(d){ return y(d.m1); })//error
                .interpolate("cardinal"); 

            svg.append("path")
                .attr("class","line")
                .attr("d",function(d){ return line(data); }) //error&lt;/PRE&gt;&lt;P&gt;The error says:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Type LineData[] is not assignable to type [number.number].&lt;/P&gt;&lt;P&gt;Property 0 is missing in the type LineData[]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;LineData is an interface and it looks like below.&lt;/P&gt;&lt;PRE&gt;export interface LineData{
        item: string;
        date: Date;
        m1: number;
        m2: number;
        m3: number;
        m4: number;
        m5: number;
        m6: number;
      }&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Feb 2018 13:43:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Custom-Visual-Line-graph/m-p/362313#M10807</guid>
      <dc:creator>satishr</dc:creator>
      <dc:date>2018-02-21T13:43:28Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Visual Line graph</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Custom-Visual-Line-graph/m-p/362385#M10810</link>
      <description>&lt;P&gt;To fix the issue you faced you should&amp;nbsp;cast &lt;STRONG&gt;d3.svg.line&lt;/STRONG&gt; to &lt;STRONG&gt;LineData&lt;/STRONG&gt; by using this code:&lt;/P&gt;
&lt;PRE&gt;var line = d3.svg.line&amp;lt;LineData&amp;gt;()&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt; color: #333333;"&gt;Ignat Vilesov,&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt; color: #333333;"&gt;Software Engineer&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt; color: #333333;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt; color: #333333;"&gt;Microsoft Power BI Custom Visuals&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;&lt;A href="mailto:pbicvsupport@microsoft.com" target="_blank"&gt;&lt;SPAN&gt;pbicvsupport@microsoft.com&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Feb 2018 14:59:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Custom-Visual-Line-graph/m-p/362385#M10810</guid>
      <dc:creator>v-viig</dc:creator>
      <dc:date>2018-02-21T14:59:01Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Visual Line graph</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Custom-Visual-Line-graph/m-p/362445#M10812</link>
      <description>&lt;P&gt;It works perfectly now. Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Feb 2018 15:53:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Custom-Visual-Line-graph/m-p/362445#M10812</guid>
      <dc:creator>satishr</dc:creator>
      <dc:date>2018-02-21T15:53:42Z</dc:date>
    </item>
  </channel>
</rss>

